home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0018_Raw Speaker Support.pas < prev    next >
Pascal/Delphi Source File  |  1993-06-08  |  2KB  |  65 lines

  1. (*
  2. ===========================================================================
  3.  BBS: Canada Remote Systems
  4. Date: 05-31-93 (17:52)             Number: 24475
  5. From: MARK LEWIS                   Refer#: NONE
  6.   To: CHARLES LUMIA                 Recvd: NO
  7. Subj: PC SPEAKER AND RAW SO          Conf: (1221) F-PASCAL
  8. ---------------------------------------------------------------------------
  9.  > Do you know how to send stuff to a PC speaker, I can't even find
  10.  > the port # for it OR how to output any data through it?
  11.  
  12. try this on for size ... these are three TP 6.0 Assembler routines that "mimic"
  13. the same ones that come in TP's CRT unit. DELAY was given to me by Sean Palmer
  14. (thanks sean! it works as advertised -=B-) and the other two i hacked out
  15. myself...
  16.  
  17. procedure delay(ms : word); Assembler;
  18. {ms is the number of milliseconds to delay. 1000ms = 1second}
  19. *)
  20.  
  21. asm
  22.   mov ax,1000
  23.   mul ms
  24.   mov cx,dx
  25.   mov dx,ax
  26.   mov ah,$86
  27.   int $15
  28. end;
  29.  
  30. procedure sound( hertz : word); Assembler;
  31. {hertz is the sound frequency to send to the speaker port}
  32.  
  33. asm
  34.   MOV    BX,SP
  35.   MOV    BX,&hertz
  36.   MOV    AX,34DDh
  37.   MOV    DX,0012h
  38.   CMP    DX,BX
  39.   JNB    @J1
  40.   DIV    BX
  41.   MOV    BX,AX
  42.   IN     AL,61h
  43.   TEST   AL,03h
  44.   JNZ    @J2
  45.   OR     AL,03h
  46.   OUT    61h,AL
  47.   MOV    AL,-4Ah
  48.   OUT    43h,AL
  49. @J2:
  50.   MOV    AL,BL
  51.   OUT    42h,AL
  52.   MOV    AL,BH
  53.   OUT    42h,AL
  54. @J1:
  55. end;
  56.  
  57. procedure nosound; Assembler;
  58. {turns the speaker off}
  59. asm
  60.   IN     AL,61h
  61.   AND    AL,0FCh
  62.   OUT    61h,AL
  63. end;
  64.  
  65.